home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr50 / pbwiz17.zip / ARCVIEW.BAS < prev    next >
BASIC Source File  |  1993-06-18  |  4KB  |  110 lines

  1. '   +----------------------------------------------------------------------+
  2. '   |                                                                      |
  3. '   |         PBWIZ  Copyright (c) 1991-1993  Thomas G. Hanlin III         |
  4. '   |                                                                      |
  5. '   |                      PowerBASIC Wizard's Library                     |
  6. '   |                                                                      |
  7. '   +----------------------------------------------------------------------+
  8.  
  9. ' This is another simple demo of the PBWiz routines.  It allows you to
  10. ' view the files in an archive (.ARC, .ARJ, .LZH, .PAK, .ZIP, or .ZOO).
  11.  
  12. ' Syntax:
  13. '   ARCVIEW arcname[.ext] [/V]
  14.  
  15. ' The file extension for the archive is optional, although you may want to
  16. ' specify it if there is a possibility that you have two archives of the
  17. ' same name but different extensions (e.g., FOO.ARJ and FOO.ZIP).  The /V
  18. ' option allows you to specify a full listing-- without it, you will get
  19. ' a "wide format" display containing just the file names in the archive.
  20.  
  21.    $DIM ARRAY
  22.  
  23.    DECLARE SUB CloseA ()
  24.    DECLARE SUB FindFirstA (STRING, STRING, INTEGER)
  25.    DECLARE SUB FindNextA (INTEGER)
  26.    DECLARE FUNCTION GetCRCA$ ()
  27.    DECLARE FUNCTION GetDateA$ ()
  28.    DECLARE FUNCTION GetNameA$ ()
  29.    DECLARE SUB GetSizeA (LONG, LONG)
  30.    DECLARE FUNCTION GetTimeA$ ()
  31.  
  32.    DECLARE SUB GetComma (LONG, INTEGER)
  33.  
  34.    OPTION BINARY BASE 1
  35.  
  36.    $LINK "pbwiz.pbl"
  37.  
  38.    DEFINT A-Z
  39.  
  40.    Cmd$ = LTRIM$(RTRIM$(UCASE$(COMMAND$)))
  41.    IF INSTR(Cmd$, "/?") THEN
  42.       PRINT "ARCVIEW: View Archive Demo for PBWiz by Thomas G. Hanlin III"
  43.       PRINT
  44.       PRINT "Syntax:"
  45.       PRINT "  ARCVIEW arcname[.ext] [/V]
  46.       PRINT
  47.       PRINT "Use /V for a full listing, as opposed to just a list of the files contained"
  48.       PRINT "in the archive.  ARCVIEW currently supports ARC, ARJ, EXE, LZH, PAK, ZIP,"
  49.       PRINT "and ZOO."
  50.       END
  51.    END IF
  52.    tmp = INSTR(Cmd$, "/V")
  53.    IF tmp THEN
  54.       FullView = -1
  55.       Cmd$ = LTRIM$(RTRIM$(LEFT$(Cmd$, tmp - 1) + MID$(Cmd$, tmp + 2)))
  56.    END IF
  57.    IF LEN(Cmd$) THEN
  58.       Arc$ = Cmd$
  59.    ELSE
  60.       PRINT "Please specify the name of an archive."
  61.       END
  62.    END IF
  63.  
  64.    FindFirstA Arc$, "*.*", ErrCode
  65.    IF ErrCode THEN
  66.       PRINT "Unable to open archive "; CHR$(34); Arc$; CHR$(34)
  67.       END
  68.    END IF
  69.  
  70.    IF FullView THEN
  71.       PRINT "Filename       Date       Time    CRC        Curr. Size    Orig. Size"
  72.       PRINT "------------   --------   -----   --------   -----------   -----------"
  73.    END IF
  74.  
  75.    DO
  76.       FileName$ = GetNameA$
  77.       IF FullView THEN
  78.          PRINT FileName$; SPACE$(15 - LEN(FileName$));
  79.          DateSt$ = LEFT$(GetDateA$, 6) + RIGHT$(GetDateA$, 2)
  80.          TimeSt$ = LEFT$(GetTimeA$, 5)
  81.          PRINT DateSt$; "   "; TimeSt$; "   "; GetCRCA$;
  82.          GetSizeA OriginalSize&, CurrentSize&
  83.          PrintComma CurrentSize&, 14
  84.          PrintComma OriginalSize&, 14
  85.          PRINT
  86.       ELSE
  87.          PRINT FileName$; SPACE$(16 - LEN(FileName$));
  88.       END IF
  89.       FindNextA ErrCode
  90.    LOOP UNTIL ErrCode
  91.  
  92.    CloseA
  93.  
  94.    IF NOT FullView THEN PRINT
  95.  
  96. SUB PrintComma (Number&, FieldLen)
  97.    N$ = LTRIM$(STR$(Number&))
  98.    R$ = ""
  99.    DO WHILE LEN(N$) > 3
  100.       R$ = RIGHT$(N$, 3) + "," + R$
  101.       N$ = LEFT$(N$, LEN(N$) - 3)
  102.    LOOP
  103.    IF LEN(N$) THEN R$ = N$ + "," + R$
  104.    IF RIGHT$(R$, 1) = "," THEN R$ = LEFT$(R$, LEN(R$) - 1)
  105.    IF LEN(R$) < FieldLen THEN
  106.       R$ = SPACE$(FieldLen - LEN(R$)) + R$
  107.    END IF
  108.    PRINT R$;
  109. END SUB
  110.